package com.water.camera.mark;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.water.camera.bean.EditItem;
import com.water.camera.databinding.LayoutWatermark33Binding;
import com.water.camera.util.Utils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class Mark33 extends BaseMark {

    LayoutWatermark33Binding binding;

    public Mark33(@NonNull Context context) {
        super(context);
    }

    public Mark33(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Mark33(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(int type) {
        if (type == 0) {
            binding = LayoutWatermark33Binding.inflate(LayoutInflater.from(getContext()));
            addView(binding.getRoot());
        } else {
            binding = LayoutWatermark33Binding.inflate(LayoutInflater.from(getContext()), this, true);
        }
        update();
        if (type == 0) {
            hideView(binding.bottom);
        }
    }

    @Override
    public void update() {
        setText(binding.binding2, "jingwei33", binding.binding2);

        setText(binding.binding4, "time33", binding.binding4);
        setTime(binding.binding4, new SimpleDateFormat("yyyy.MM.dd"));

        setText(binding.binding5, "didian33", binding.binding5);

        super.update();
    }

    @Override
    public ArrayList<EditItem> getEditItems() {
        ArrayList<EditItem> list = new ArrayList<>();
        list.add(new EditItem("jingwei33", "经纬度"));
        list.add(new EditItem("time33", "时间", true));
        list.add(new EditItem("didian33", "地点"));
        return list;
    }

    @Override
    public void onValueChange(EditItem item) {
        if (item.isTime) {
            setTime(binding.binding4, new SimpleDateFormat("yyyy.MM.dd"));
        } else {
            super.onValueChange(item);
        }
    }
}
